import { $rp } from '@/utils/constants';
import SpacesIndex from '@/views/spaces/index';
import SpaceShow from '@/components/spaces/Show';
import SpaceCreate from '@/components/spaces/Create';
import SpaceHomepage from '@/components/spaces/homepage';
import GroupsIndex from '@/views/groups/index/space-groups';
import GroupsCreate from '@/views/groups/create';
import SpaceSettings from '@/components/spaces/settings';

import spaceResources from './space_resources';
import spaceIssues from './space_issues';
import spaceContributions from './space_contributions';

export default [
  {
    path: `/${$rp.SPACES}`,
    alias: [
      '/spaces/history',
      '/spaces/all',
      '/spaces/collection',
      '/spaces/admin',
    ],
    component: SpacesIndex,
    meta: { requireAuth: true },
  },
  {
    path: `/${$rp.SPACES}/${$rp.CREATE}`,
    component: SpaceCreate,
  },
  {
    path: `/${$rp.SPACES}/${$rp.JOIN}`,
    component: SpaceShow,
    meta: { requireAuth: true },
  },
  {
    path: `/${$rp.SPACES}/:spaceId`,
    component: SpaceShow,
    meta: { sidebar: true },
    children: [
      {
        path: $rp.SPACE_HOMEPAGE,
        alias: '',
        component: SpaceHomepage,
      },
      ...spaceResources,
      ...spaceIssues,
      ...spaceContributions,
      {
        path: 'groups',
        component: GroupsIndex,
      },
      {
        path: 'groups/new',
        component: GroupsCreate,
        meta: { requireAuth: true },
      },
      {
        path: $rp.SETTINGS,
        component: SpaceSettings,
        meta: { requireAuth: true },
      },
    ],
  },
];
